package cn.tedu.charging.device.controller;

import cn.tedu.charging.common.pojo.vo.JsonResult;
import cn.tedu.charging.common.pojo.param.GunStatusUpdateParam;
import cn.tedu.charging.common.pojo.vo.StationInfoVO;
import cn.tedu.charging.device.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/device")
@Api(tags = "设备接口")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    @ApiOperation("获取场站信息")
    @RequestMapping("/get/station/info/{gunId}")
    public JsonResult<StationInfoVO> getStationInfo(@PathVariable("gunId")Integer gunId){
        log.debug("获取场站信息:{}",gunId);
        StationInfoVO stationInfoVO = deviceService.getStationInfo(gunId);
        JsonResult ok = JsonResult.ok(stationInfoVO);
        log.debug("获取场站信息:{},出参:{}",gunId,ok);
        return ok;
    }

    @ApiOperation("更新枪状态")
    @PostMapping("/update/gun/status")
    public JsonResult<Boolean> updateGunStatus(@RequestBody GunStatusUpdateParam param){
        log.debug("获取场站信息:{}",param);
        Boolean isSuccess = deviceService.updateGunStatus(param);
        JsonResult ok = JsonResult.ok(isSuccess);
        log.debug("获取场站信息:{},出参:{}",param,ok);
        return ok;
    }
}
